<h1><span></span><?= lang('label_deals') . ' (' . count($deals) . ')' ?></h1>

<ul class="breadcrumb">
    <li><a href="<?= base_url() ?>"><?= lang('label_home') ?></a></li>
    <li><a href="<?= base_url("store") ?>"><?= lang('label_menu_link_mystore') ?></a></li>
    <li><?= lang('label_deals') ?></li>
</ul>


<div class="page">
    <?php if (count($deals) > 0) { ?>
        <table id="tablestyle2">
            <thead>
                <tr>
                    <th><?= lang('label_inv_num') ?></th>
                    <th><?= lang('label_products') ?></th>
                    <th><?= lang('label_type') ?></th>
                    <th><?= lang('label_decision') ?></th>
                    <th><?= lang('label_operation') ?></th>
                </tr>
            </thead>

            <tbody>
                <?php foreach ($deals as $deal) { ?>
                    <tr <?php if ($deal->seen == 'NO') { ?>style='background-color: #e8f9fd;'<?php } ?>>
                        <td><?= strtoupper($deal->inv_num) ?></td>
                        <td><?php
                            $prod = get_item_data($deal->item_id);
                            if (isset($prod['id']) && isset($prod['title'])) {
                                ?>
                                <a href="<?= base_url('products/view/' . $prod['id']) ?>" target="_blank"><?= $prod['title'] ?></a>
                            <?php } ?>
                        </td>
                        <td><?= lang('label_deal_need_' . strtolower($deal->type));
                            if($deal->sent == 'YES') echo '<br />('.lang('label_product_sent').')'
                            ?></td>
                        <td><?php if ($deal->accept == 'YES') { ?>
                                <span style="color: green"><?= lang('label_you_accept') ?></span>
                            <?php } elseif ($deal->canceled == 'YES') { ?>
                                <span style="color: red"><?= lang('label_you_refuse') ?></span>
                            <?php } else { ?>
                                <span><a href="<?= base_url("store/showdeal/$deal->item_id/$deal->inv_num") ?>"><?= lang('label_take_decision') ?></a></span>
                            <?php } ?>
                        </td>
                        <td><a href="<?= base_url("store/showdeal/$deal->item_id/$deal->inv_num") ?>"><?= lang('label_details') ?></a>
                            <?php if ($deal->type == 'SEND') { ?>
                                <span> | <a href="<?= base_url("store/shipingdetails/$deal->id/$deal->inv_num") ?>"><?= lang('label_shiping_details') ?></a></span>
                            <?php } ?>
                        </td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
    <?php } else { ?>
        <div class="unsaved">
            <img src="<?php echo str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) ?>/<?php echo APPPATH ?>views/<?php echo $this->themes->Cms_themes() ?>/images/unsaved.png" alt="" />
            <br /><?= lang('message_dont_have_deals') ?>
        </div>
        <br /><br /><br /><br />
    <?php } ?>
</div>
